package leecode

import (
	"fmt"
	"math"
)

func sumOfEncryptedInt(nums []int) int {
	var result int
	for _, num := range nums {
		if num < 10 {
			result += num
		} else {
			result += analysis(num)
		}
	}
	return result
}

func analysis(num int) int {
	index := 0
	ans := math.MinInt

	for num > 0 {
		ans = max(ans, num%10)
		num = num / 10
		index++
	}
	fmt.Println("index ", index, "ans ", ans)
	result := ans
	for i := 1; i < index; i++ {
		result = result*10 + ans
	}
	return result
}
